package cn.bookCity.serviceimpl;

import java.util.List;

import cn.bookCity.dao.ProductDao;
import cn.bookCity.domain.Products;
import cn.bookCity.service.ProductService;
import cn.bookCity.util.BeanFactory;

public class ProductServiceImpl implements ProductService {

	@Override
	public int getCount() {
		ProductDao productDao=(ProductDao)BeanFactory.getBean("ProductDao");
		return productDao.getCount();
	}

	@Override
	public List<Products> getPageProducts(int startNo, int pagesize) {
		ProductDao productDao=(ProductDao)BeanFactory.getBean("ProductDao");
		return productDao.getPageProducts(startNo, pagesize);
	}

	@Override
	public Products getProduct(String id) {
		ProductDao productDao=(ProductDao)BeanFactory.getBean("ProductDao");
		return productDao.getProductById(id);
	}

	@Override
	public List<Products> getProductByName(String keywords) {
		ProductDao productDao=(ProductDao)BeanFactory.getBean("ProductDao");
		return productDao.getProduct(keywords);
	}

	@Override
	public List<Products> getAllBooks() {
		ProductDao productDao=(ProductDao)BeanFactory.getBean("ProductDao");
		return productDao.getAllBooks();
	}

	@Override
	public void addProduct(Products products) {
		ProductDao productDao=(ProductDao)BeanFactory.getBean("ProductDao");
		productDao.addProduct(products);
	}

	@Override
	public void delProduct(String id) {
		ProductDao productDao = (ProductDao)BeanFactory.getBean("ProductDao");
		productDao.delProduct(id);
	}

}
